package cn.iocoder.yudao.module.apijson.framework;

import apijson.JSON;
import apijson.Log;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class ApiJsonInitializer implements ApplicationListener<ApplicationReadyEvent> {
    public void init() throws Exception {
        JSON.DEFAULT_JSON_PARSER = new JSONParser();
        Log.DEBUG=false;
        APIJSONVerifier.ENABLE_VERIFY_CONTENT=false;
        APIJSONApplication.init(true);

    }

    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        try {
            init();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
